package com.example.fw;

import com.example.tests.AddressData;
import com.example.tests.GroupData;
import com.example.tests.PhoneData;
import com.example.utils.ListOf;
import com.example.utils.SortedListOf;

import java.util.List;

public class ApplicationModel {

    private SortedListOf<GroupData> groupList;
    private SortedListOf<AddressData> addressList;

    public ListOf<PhoneData> getPhoneList() {
        ListOf<PhoneData> phoneList = new ListOf<PhoneData>();
        for (AddressData addressData : addressList){
            phoneList.add(new PhoneData(addressData));
        }
        return phoneList;
    }

    public SortedListOf<AddressData> getAddressList() {
        return addressList;
    }

    public SortedListOf<GroupData> getGroupList() {
        return groupList;
    }

    public void setGroupList(List<GroupData> groupList) {
        this.groupList = new SortedListOf<GroupData>(groupList);
    }

    public void setAddressList(List<AddressData> addressList) {
        this.addressList = new SortedListOf<AddressData>(addressList);
    }

    public ApplicationModel addGroup(GroupData groupData) {
        groupList.add(groupData);
        return this;
    }

    public ApplicationModel removeGroup(int groupIndex) {
        groupList.remove(groupIndex);
        return this;
    }

    public ApplicationModel addAddress(AddressData addressData) {
        addressList.add(addressData);
        return this;
    }

    public ApplicationModel removeAddress(int addressIndex) {
        addressList.remove(addressIndex);
        return this;
    }
}
